package demo.practice.array;

import java.util.Arrays;

public class P455 {

    public static void main(String[] args) {
        P455 p455 = new P455();
        p455.findContentChildren(new int[]{1,2,3},new int[]{3});
    }

    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);

        int sum = 0;
        for (int i = 0; i < g.length; i++) {
            //拿到人 需要的饼干的一个元素
            int cur = g[i];
            for (int j = 0; j < s.length; j++) {

                //满足胃口
                if (cur <= s[j]) {
                    sum++;
                    s[j] = -1;
                    break;
                }
            }
        }
        return sum;
    }


}
